from configparser import ConfigParser
from pathlib import Path
import pandas as pd

def get_config_from(file_path: Path):
    conf = ConfigParser()
    
    conf.read(file_path)
    
    return conf.getfloat('config', 'qos_constraint')

def get_data_from(file_path: Path):
    return pd.read_csv(file_path)

def get_ans_from(file_path: Path):
    with open(file_path, 'r') as f:
        raw = f.read().splitlines()
        output = [(j.split(':')[0], {i.split(',')[0]: int(i.split(',')[1]) for i in j.split(":")[1][1:-1].split('>,<')} if j[-1] != ':' else None) for j in raw]
    
    return output